package me.bay.gt.java.config;

import me.bay.gt.java.beans.Klass;
import me.bay.gt.java.beans.School;
import me.bay.gt.java.beans.Student;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;

@Configuration
public class AppConfig {
    @Bean
    public Student student1() {
        Student student = new Student();
        student.setId(1);
        student.setName("bay");
        return student;
    }

    @Bean
    public Student student2() {
        Student student = new Student();
        student.setId(2);
        student.setName("JayZhou");
        return student;
    }

    @Bean
    public Klass class1() {
        Klass c = new Klass();
        c.setStudents(new ArrayList<Student>() {{
            add(student1());
            add(student2());
        }});
        return c;
    }

    @Bean
    public School school() {
        School school = new School();
        school.setClass1(class1());
        return school;
    }
}
